package com.tib.controllers;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.tib.mock.MockModuleProvider;

@Controller
public class CountriesController {
	
	@PostConstruct
	public void CiesController(){
		System.out.println("Class loaded");
	}

	@RequestMapping("/")
	public String getAllCountries(Model model){
		System.out.println("I am here!");
		model.addAttribute("countries", MockModuleProvider.getCountries());		
		return "all";
	}
	
	@RequestMapping("/region")
	public String getRegion(@RequestParam("country") String countryName, @RequestParam("region") String regionName, Model model){
		System.out.println("I am here 2!");
		model.addAttribute("region", MockModuleProvider.getRegion());
		model.addAttribute("country_name", countryName);
		return "region";
	}
	
	
	
}
